home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / quicktimeintro / sequence grabbing / completed lab / putfile.c next >
Encoding:
C/C++ Source or Header  |  2000-10-06  |  2.7 KB  |  94 lines

  1. #include "SequenceGrab.h"
  2.  
  3. //////////
  4. //
  5. // PutFile
  6. // Save a file under the specified name. Return Boolean values indicating whether the user selected a file
  7. // and whether the selected file is replacing an existing file.
  8. //
  9. //////////
  10.  
  11. OSErr PutFile(ConstStr255Param thePrompt, ConstStr255Param theFileName, FSSpecPtr theFSSpecPtr, Boolean *theIsSelected, Boolean *theIsReplacing)
  12. {
  13. #if TARGET_OS_WIN32
  14.     StandardFileReply    myReply;
  15. #endif
  16. #if TARGET_OS_MAC
  17.     NavReplyRecord        myReply;
  18.     NavDialogOptions    myDialogOptions;
  19.     NavEventUPP            myEventUPP = NULL; // NewNavEventUPP(HandleNavEvent);
  20. #endif
  21.     OSErr                myErr = noErr;
  22.  
  23.     if ((theFSSpecPtr == NULL) || (theIsSelected == NULL) || (theIsReplacing == NULL))
  24.         return(paramErr);
  25.  
  26.     // assume we are not replacing an existing file
  27.     *theIsReplacing = false;
  28.     
  29. #if TARGET_OS_WIN32
  30.     StandardPutFile(thePrompt, theFileName, &myReply);
  31.     *theFSSpecPtr = myReply.sfFile;
  32.     *theIsSelected = myReply.sfGood;
  33.     if (myReply.sfGood)
  34.         *theIsReplacing = myReply.sfReplacing;
  35. #endif
  36.  
  37. #if TARGET_OS_MAC
  38.     // specify the options for the dialog box
  39.     NavGetDefaultDialogOptions(&myDialogOptions);
  40.     myDialogOptions.dialogOptionFlags += kNavNoTypePopup;
  41.     myDialogOptions.dialogOptionFlags += kNavDontAutoTranslate;
  42.     BlockMoveData(theFileName, myDialogOptions.savedFileName, theFileName[0] + 1);
  43.     BlockMoveData(kApplicationName, myDialogOptions.clientName, kApplicationName[0] + 1);
  44.     BlockMoveData(thePrompt, myDialogOptions.message, thePrompt[0] + 1);
  45.     
  46.     // prompt the user for a file
  47.     myErr = NavPutFile(NULL, &myReply, &myDialogOptions, myEventUPP, MovieFileType, sigMoviePlayer, NULL);
  48.     if ((myErr == noErr) && myReply.validRecord) {
  49.         AEKeyword        myKeyword;
  50.         DescType        myActualType;
  51.         Size            myActualSize = 0;
  52.         
  53.         // get the FSSpec for the selected file
  54.         if (theFSSpecPtr != NULL)
  55.             myErr = AEGetNthPtr(&(myReply.selection), 1, typeFSS, &myKeyword, &myActualType, theFSSpecPtr, sizeof(FSSpec), &myActualSize);
  56.  
  57.         NavDisposeReply(&myReply);
  58.     }
  59.         
  60.     *theIsSelected = myReply.validRecord;
  61.     if (myReply.validRecord)
  62.         *theIsReplacing = myReply.replacing;
  63.  
  64.     DisposeNavEventUPP(myEventUPP);
  65. #endif
  66.  
  67.     return(myErr);
  68. }
  69.  
  70. //////////
  71. //
  72. // QTFrame_HandleNavEvent
  73. // A callback procedure that handles events while a Navigation Service dialog box is displayed.
  74. //
  75. //////////
  76.  
  77. PASCAL_RTN void HandleNavEvent (NavEventCallbackMessage theCallBackSelector, NavCBRecPtr theCallBackParms, void *theCallBackUD)
  78. {
  79. #pragma unused(theCallBackUD)
  80.     WindowReference        myWindow = NULL;    
  81.     
  82.     if (theCallBackSelector == kNavCBEvent) {
  83.         switch (theCallBackParms->eventData.eventDataParms.event->what) {
  84.             case updateEvt:
  85. #if TARGET_OS_MAC
  86.                 // Handle Update Event
  87. #endif
  88.                 break;
  89.             case nullEvent:
  90.                 // Handle null Event
  91.                 break;
  92.         }
  93.     }
  94. }